home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / mflms101.arc / MFLTIME.H < prev    next >
C/C++ Source or Header  |  1989-11-25  |  8KB  |  178 lines

  1. /************************************************************************/
  2. /*                                                                      */
  3. /*  MFLTIME Header file                                                 */
  4. /*                                                                      */
  5. /*  Function prototypes for time-related functions.                     */
  6. /*                                                                      */
  7. /*  Copyright 1989 by Robert B. Stout dba MicroFirm                     */
  8. /*  All rights reserved                                                 */
  9. /*                                                                      */
  10. /*  Copyright 1986, 1987 by S.E. Margison                               */
  11. /*                                                                      */
  12. /*  Compiled by QC 2.0 for use with MSC 5.1 or QC 2.0 or later.         */
  13. /*                                                                      */
  14. /************************************************************************/
  15.  
  16. #ifndef MFLTIME_H
  17. #define MFLTIME_H
  18.  
  19. #include <stdio.h>
  20. #include <time.h>
  21. #include <mfldefs.h>
  22.  
  23. #ifndef _Cdecl_
  24.  #ifdef NO_EXT_KEYS
  25.   #define _Cdecl_
  26.  #else
  27.   #define _Cdecl_ cdecl
  28.  #endif
  29. #endif
  30.  
  31. /************************************************************************/
  32. /*                                                                      */
  33. /*  Microsecond accuracy timing operations.                             */
  34. /*                                                                      */
  35. /************************************************************************/
  36.  
  37. typedef unsigned long uclock_t;
  38.  
  39. #define UCLK_TCK 1000000L /* Usec per second - replaces CLK_TCK         */
  40. #define usec_difftime(start,finish) (finish-start)
  41.  
  42. uclock_t _Cdecl_ usec_clock(void);
  43. void     _Cdecl_ restart_uclock(void);
  44. uclock_t _Cdecl_ usec_delay(uclock_t);
  45. LOGICAL  _Cdecl_ usec_timeout(uclock_t, uclock_t, uclock_t);
  46. void     _Cdecl_ msec_pause(long);
  47.  
  48. /************************************************************************/
  49. /*                                                                      */
  50. /*  ANSI functions                                                      */
  51. /*                                                                      */
  52. /************************************************************************/
  53.  
  54. size_t _Cdecl_ strftime(char *, size_t, const char *, const struct tm *);
  55.  
  56. /************************************************************************/
  57. /*                                                                      */
  58. /*  Julian (scalar) date functions                                      */
  59. /*                                                                      */
  60. /************************************************************************/
  61.  
  62. long     _Cdecl_ ymd_to_julian (unsigned, unsigned, unsigned);
  63. void     _Cdecl_ julian_to_ymd (long, unsigned *, unsigned *, unsigned *);
  64. int      _Cdecl_ julian_to_wkday(long);
  65. char *   _Cdecl_ julian_to_dayname(long);
  66. unsigned _Cdecl_ julian_to_yrday(long);
  67. LOGICAL  _Cdecl_ julian_to_time(long, time_t *);
  68. LOGICAL  _Cdecl_ julian_to_tm(long, struct tm *);
  69. long     _Cdecl_ time_to_julian(time_t);
  70. long     _Cdecl_ tm_to_julian(struct tm *);
  71.  
  72. /************************************************************************/
  73. /*                                                                      */
  74. /*  Structures & functions for accessing file dates and times           */
  75. /*                                                                      */
  76. /************************************************************************/
  77.  
  78. #ifndef FTIME_DEF__
  79. #define FTIME_DEF__
  80.  
  81. struct ftime {
  82.         unsigned int ft_tsec  : 5;
  83.         unsigned int ft_min   : 6;
  84.         unsigned int ft_hour  : 5;
  85.         unsigned int ft_day   : 5;
  86.         unsigned int ft_month : 4;
  87.         unsigned int ft_year  : 7;
  88.         } ;
  89.  
  90. int     _Cdecl_ getftime(int, struct ftime *);
  91. int     _Cdecl_ setftime(int, struct ftime *);
  92. int     _Cdecl_ touch(char *);
  93. void    _Cdecl_ get_filetime(struct tm *, int);
  94.  
  95. #endif /* FTIME_DEF__ */
  96.  
  97. /************************************************************************/
  98. /*                                                                      */
  99. /*  Misc functions                                                      */
  100. /*                                                                      */
  101. /************************************************************************/
  102.  
  103. void    _Cdecl_ installtick(int *),
  104.         _Cdecl_ removetick(void),
  105.         _Cdecl_ gtodsub(FILE *),
  106.         _Cdecl_ gtodstr(char *);
  107.  
  108. int     _Cdecl_ daynum(int, int, int),
  109.         _Cdecl_ isleap(unsigned),
  110.         _Cdecl_ weekday(int, int, int);
  111.  
  112. char  * _Cdecl_ monthis(int),
  113.       * _Cdecl_ wkdayname(int);
  114.  
  115. /************************************************************************/
  116. /*                                                                      */
  117. /*  Alternative file date and time functions                            */
  118. /*                                                                      */
  119. /************************************************************************/
  120.  
  121. struct DOS_TIME
  122. {
  123.         unsigned int ss : 5;
  124.         unsigned int mm : 6;
  125.         unsigned int hh : 5;
  126. } ;
  127.  
  128. struct DOS_DATE
  129. {
  130.         unsigned int da : 5;
  131.         unsigned int mo : 4;
  132.         unsigned int yr : 7;
  133. } ;
  134.  
  135. #define dos_time(t) (*(struct DOS_TIME *)(&(t)))
  136. #define dos_date(t) (*(struct DOS_DATE *)(&(t)))
  137.  
  138. /*
  139. ** Demo code for using above structures
  140. */
  141.  
  142. #if 0
  143. *************************************************************************
  144. *                                                                       * 
  145. *       /*  Sample file date and time display.*/                        *
  146. *                                                                       *
  147. *       #include <stdio.h>                                              *
  148. *       #include <dos.h>                                                *
  149. *                                                                       *
  150. *       main(int argc, char *argv[])                                    *
  151. *       {                                                               *
  152. *               struct FIND *ffblk;                                     *
  153. *                                                                       *
  154. *               if (2 > argc)                                           *
  155. *               {                                                       *
  156. *                       puts("\aUsage: SHOWDATE filename[.ext]");       *
  157. *                       exit(1);                                        *
  158. *               }                                                       *
  159. *               if (!(ffblk = findfirst(argv[1], 0xff)))                *
  160. *               {                                                       *
  161. *                       printf("\aCant find %s\n", argv[1]);            *
  162. *                       exit(2);                                        *
  163. *               }                                                       *
  164. *               printf("File date is %d-%d-%d\n",                       *
  165. *                       dos_date(ffblk->date).mo,                       *
  166. *                       dos_date(ffblk->date).da,                       *
  167. *                       (dos_date(ffblk->date).yr + 80) % 100);         *
  168. *               printf("File time is %d:%d:%d\n",                       *
  169. *                       dos_time(ffblk->time).hh,                       *
  170. *                       dos_time(ffblk->time).mm,                       *
  171. *                       dos_time(ffblk->time).ss);                      *
  172. *                       }                                               *
  173. *                                                                       *
  174. *************************************************************************
  175. #endif /* 0 */
  176.  
  177. #endif /* MFLTIME_H */
  178.